using DynamicChart.Service.FunctionConversion;

namespace DynamicChart.Service.Interpreter;

public class DateTypeInterpreter : IParamInterpreter
{
    private readonly ISqlFunctionAdapter _sqlFunctionAdapter;

    public DateTypeInterpreter(ISqlFunctionAdapter sqlFunctionAdapter)
    {
        _sqlFunctionAdapter = sqlFunctionAdapter;
    }
    
    public string Name => "dateType";
    public void Interpret(ref string value, IDictionary<string, object> param)
    {
        if (!param.TryGetValue("dateType", out var dateType)) return;
        var dateTypeStr = dateType.ToString()!.ToLower();
        param["dateType"] = _sqlFunctionAdapter.GetDateFormat(dateTypeStr);
    }
}